#ifndef __MINIKIT_CONFIG_H__
#define __MINIKIT_CONFIG_H__
#include <string>
#include <map>
#include <stdint.h>
#include <ostream>
#include <exception>

namespace MINIKIT
{

class Config
{
public:
	typedef std::map<std::string, std::string> SectionConfig;
//    Config();
//    virtual ~Config();

//    void clear();
    //std::string Trim(std::string &str);
//    int32_t Read(const std::string &conf_file);
//    std::string GetStr(const std::string &sName);
//    int32_t GetInt(const std::string &sName);
    
public:
	Config();
	Config(const std::string& filepath);
	virtual ~Config();

private://TODO: implement the assigning operation?
	Config(const Config& other);

public:
	void  setItem( 
		const std::string& sec, 
		const std::string& key, 
		const std::string& val
	);

	const std::string& getItem( 
		const std::string& sec, 
		const std::string& key, 
		const std::string& defval
	);

	int32_t getInt32(
		const std::string& sec, 
		const std::string& key, 
		int32_t            defval = 0
	);

	int64_t getInt64(
		const std::string& sec, 
		const std::string& key, 
		int64_t            defval = 0
	);

	const std::string& getStr(
		const std::string& sec, 
		const std::string& key, 
		const std::string& defval = ""
	);
	
	void    setFile( const std::string& filepath );
	int32_t reload() throw(std::exception);
	void    output(std::ostream &s);

protected:
	std::string   filepath;
	std::map<std::string, SectionConfig> section_map;	

};//class Config


class GlobalConfig:public Config
{
public:
    static GlobalConfig &GetInstance()
    {
    	static GlobalConfig _instance;
        return _instance;
    }
private:
    GlobalConfig(){}
    ~GlobalConfig(){}

};//class GlobalConfig


};//namespace MINIKIT

#endif /*__MINIKIT_CONFIG_H__*/

